// 用户相关请求模块
import request from '@/utils/request'
// import store from '@/store'
// 登录
export const login = data => request({
  method: 'POST',
  url: '/v1_0/authorizations',
  data
})
// 获取短信验证码
export const sendSms = mobile => request({
  method: 'GET',
  url: `/v1_0/sms/codes/${mobile}`
})
// 获取用户自己的信息
export const getUserInfo = () => request({
  method: 'GET',
  url: '/v1_0/user'
  // headers: { // headers的首字母小写
  //   // 在请求头的Authorization中携带token ！！！千万记得是user.token
  //   Authorization: `Bearer ${store.state.user.token}`
  // }
})
// 获取用户频道列表
export const getUserChannels = () => request({
  method: 'GET',
  url: 'http://toutiao.itheima.net/v1_0/user/channels'
})
// 点击关注作者 传作者ID
export const addFollow = autID => request({
  method: 'POST',
  url: '/v1_0/user/followings',
  data: {
    target: autID
  }
})
// 点击取消关注 传作者ID
export const deleteFollow = autID => request({
  method: 'DELETE',
  url: `/v1_0/user/followings/${autID}`
})
// 点击收藏文章 传文章ID
export const addCollect = artID => request({
  method: 'POST',
  url: '/v1_0/article/collections',
  data: {
    target: artID
  }
})
// 点击取消收藏文章 传文章ID
export const deleteCollec = artID => request({
  method: 'DELETE',
  url: `/v1_0/article/collections/${artID}`
})
// 获取个人信息
export const getUserFile = () => request({
  method: 'GET',
  url: '/v1_0/user/profile'
})
// 更新个人信息
export const updateUserFile = data => request({
  method: 'PATCH',
  url: '/v1_0/user/profile',
  data
})
// 更新头像
export const updateUserPhoto = data => request({
  method: 'PATCH',
  url: '/v1_0/user/photo',
  data
})
